package com.spring.security.handler;

import com.spring.security.model.JsonResult;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author HouKunLin
 */
@Component
public class LogoutSuccessHandler implements org.springframework.security.web.authentication.logout.LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        response.setContentType("text/json");
        response.setCharacterEncoding("UTF-8");
        JsonResult json = JsonResult.ok("退出成功");
        response.getWriter().print(json.toJSONString());
    }
}
